package socket.demo;

import java.io.*;
import java.net.Socket;

public class SocketClient {
  public static void main(String[] args) {
    try {
      // 这个是建立 客户端 socket
      Socket client = new Socket("192.168.56.11", 9111);
      
      // 设置web socket 参数
      client.setSendBufferSize(20);
      client.setTcpNoDelay(false);
      // 拿到 socket 输出流
      OutputStream outputStream = client.getOutputStream();
      
      InputStream in = System.in;
      BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(in));
      
      while (true) {
        String line = bufferedReader.readLine();
        if (line != null) {
          byte[] bb = line.getBytes();
          for (byte b : bb)
            outputStream.write(b);
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
